home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’96 / PredatorPrey / Windowing.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-22  |  5.5 KB  |  206 lines  |  [TEXT/KAHL]

  1. /* © 1988-91, Bowers Development Corp. */
  2. /* Windowing.c */
  3.  
  4. #include <Types.h>
  5. #include <Quickdraw.h>
  6. #include <Controls.h>
  7. #include <Dialogs.h>
  8. #include <Events.h>
  9. #include <Lists.h>
  10. #include <Menus.h>
  11. #include <TextEdit.h>
  12. #include "Globals.h"
  13. #include "Scrolling.h"
  14. #include "Miscellany.h"
  15. #include "FileM.h"
  16. #include "Dispatcher.h"
  17.  
  18. #include "Windowing.h"
  19. #ifndef __C14__
  20. #include    "PredatorPrey.h"
  21. #endif
  22.  
  23. #include <ToolUtils.h>
  24. #include <Script.h>
  25.  
  26. #define topLeft(r)    (((Point *) &(r))[0])
  27. #define botRight(r)    (((Point *) &(r))[1])
  28.  
  29. void    WindowingSeg()    {}
  30.  
  31. #pragma segment Windowing
  32.  
  33.     
  34. /*----------*/
  35. void DoContent    (WindowPtr        whichWindow)
  36. {
  37.     Point            where;
  38.     ControlHandle    whichControl;
  39.     short            partCode;
  40.     Boolean            extendSel;
  41.  
  42.     if (whichWindow != FrontWindow ()) {
  43.         SelectWindow (whichWindow);
  44.     } else {
  45.         where = gTheEvent.where;
  46.         GlobalToLocal (&where);
  47.     
  48.         partCode = FindControl (where, whichWindow, &whichControl);
  49.     
  50.         if (whichControl == NULL) {
  51.             extendSel = ((gTheEvent.modifiers & shiftKey) != 0);
  52.             if ((cur->text != NULL)
  53.              && PtInRect (where, &((**(cur->text)).viewRect))) {
  54.                 TEClick (where, extendSel, cur->text);
  55.             } else {
  56.                 MouseInContent (where, gTheEvent.modifiers);
  57.             }
  58.         } else {
  59.             if ((whichControl == cur->vScroll)
  60.             ||  (whichControl == cur->hScroll)) {
  61.                 TrackScroll (whichControl, partCode, where, &ScrollWindow);
  62.             } else {
  63.                 DoControl (whichControl, partCode, where);    /* dispatcher.c */
  64.             }
  65.         }    
  66.      }
  67. } /*DoContent*/
  68.  
  69. /*----------*/
  70. void DoDrag        (WindowPtr        whichWindow)
  71. {
  72.     RgnHandle        grayRgn;
  73.     Rect            limitRect;
  74.  
  75.     grayRgn = GetGrayRgn ();
  76.      limitRect = (**grayRgn).rgnBBox;
  77.     DragWindow (whichWindow, gTheEvent.where, &limitRect);
  78. } /*DoDrag*/
  79.  
  80. /*----------*/
  81. /*void InvalGrowBox    (WindowPtr        whichWindow);*/
  82. /*void InvalGrowBox    (WindowPtr        whichWindow)*/
  83. /*{*/
  84. /*    Rect            growBox;*/
  85. /*    */
  86. /*    #define port    whichWindow->portRect*/
  87. /*    SetRect (&growBox, port.right - 15, port.bottom - 15,*/
  88. /*                       port.right,        port.bottom);*/
  89. /*    InvalRect (&growBox);*/
  90. /*    #undef port*/
  91. /*}*/ /*InvalGrowBox*/
  92.  
  93. /*----------*/
  94. /*void DoGrow        (WindowPtr        whichWindow)*/
  95. /*{*/
  96. /*    #define minWidth       55                                 */
  97. /*    #define minHeight      55                                */
  98. /*    #define maxint      32767                                */
  99. /**/
  100. /*    RgnHandle        grayRgn;*/
  101. /*    short            maxWidth;*/
  102. /*    short            maxHeight;*/
  103. /*    Rect            sizeRect;*/
  104. /*    long            newSize;*/
  105. /*    short            newWidth;*/
  106. /*    short            newHeight;*/
  107. /*    */
  108. /*    grayRgn = GetGrayRgn ();*/
  109. /*     sizeRect = (**grayRgn).rgnBBox;*/
  110. /*    maxWidth  = (sizeRect.right  - sizeRect.left);*/
  111. /*    maxHeight = (sizeRect.bottom - sizeRect.top) - GetMBarHeight ();*/
  112. /**/
  113. /*    SetRect (&sizeRect, minWidth, minHeight, maxint, maxint);*/
  114. /*    newSize = GrowWindow (whichWindow, curEvent.where, &sizeRect);*/
  115. /*    if (newSize != 0) {*/
  116. /*        InvalGrowBox (whichWindow);    /* old position »*/
  117. /*        newWidth  = LoWord (newSize);*/
  118. /*        newHeight = HiWord (newSize);*/
  119. /*        SizeWindow (whichWindow, newWidth, newHeight, true);*/
  120. /*        ResizeContent ();*/
  121. /*        ResizeScrollBars ();*/
  122. /*        InvalGrowBox (whichWindow);    /* new position »*/
  123. /*    }*/
  124. /*}*/ /*DoGrow*/
  125.  
  126. /*----------*/
  127. void DoGoAway    (WindowPtr        whichWindow,EventRecord    gTheEvent)
  128. {
  129.     if (TrackGoAway (whichWindow, /*curEvent.where*/gTheEvent.where)) {
  130.         DoClose ();
  131.     }
  132. } /*DoGoAway*/
  133.  
  134. /*----------*/
  135. /*void    SetZoomRect (WindowPtr        whichWindow,*/
  136. /*                     short            inOrOut);*/
  137. /*void    SetZoomRect (WindowPtr        whichWindow,*/
  138. /*                     short            inOrOut)*/
  139. /*{*/
  140. /*    Rect            windRect;*/
  141. /*    Rect            theSect;*/
  142. /*    Rect            zoomRect;*/
  143. /*    Rect            gdRect;*/
  144. /*    GDHandle        nthDevice;*/
  145. /*    GDHandle        dominantGDevice;*/
  146. /*    long            sectArea;*/
  147. /*    long            greatestArea;*/
  148. /*    short            bias;*/
  149. /*    Boolean            sectFlag;*/
  150. /*    GrafPtr            savePort;*/
  151. /**/
  152. /*    if (TrackBox (whichWindow, curEvent.where, inOrOut)) {*/
  153. /*        GetPort (&savePort);*/
  154. /*        SetPort (whichWindow);*/
  155. /*        EraseRect (&whichWindow->portRect);*/
  156. /*        windRect = whichWindow->portRect;*/
  157. /*        LocalToGlobal (&topLeft (windRect));*/
  158. /*        LocalToGlobal (&botRight (windRect));*/
  159. /*        bias = windRect.top - 1 - (**(((WindowPeek) whichWindow)->strucRgn)).rgnBBox.top;*/
  160. /*        windRect.top = windRect.top - bias;*/
  161. /*        nthDevice = GetDeviceList ();*/
  162. /*        greatestArea = 0;*/
  163. /**/
  164. /*        while (nthDevice != NULL) {*/
  165. /*            if (TestDeviceAttribute (nthDevice, screenDevice)) {*/
  166. /*                if (TestDeviceAttribute (nthDevice, screenActive)) {*/
  167. /*                    gdRect = (**nthDevice).gdRect;*/
  168. /*                    sectFlag = SectRect (&windRect, &gdRect, &theSect);*/
  169. /*                    sectArea = ((long) (theSect.right - theSect.left))*/
  170. /*                               * (theSect.bottom - theSect.top);*/
  171. /*                    if (sectArea > greatestArea) {*/
  172. /*                        greatestArea = sectArea;*/
  173. /*                        dominantGDevice = nthDevice;*/
  174. /*                    }*/
  175. /*                    nthDevice = GetNextDevice (nthDevice);*/
  176. /*                }*/
  177. /*            }*/
  178. /*        } /*while»*/
  179. /**/
  180. /*        if (dominantGDevice == GetMainDevice ()) {*/
  181. /*            bias = bias + GetMBarHeight ();*/
  182. /*        }*/
  183. /*        gdRect = (**dominantGDevice).gdRect;*/
  184. /*        SetRect (&zoomRect, gdRect.left + 3, gdRect.top + bias + 3, gdRect.right - 3, gdRect.bottom - 3);*/
  185. /*        (**(WStateDataHandle) (((WindowPeek) whichWindow)->dataHandle)).stdState = zoomRect;*/
  186. /*    }*/
  187. /*}*/ /*SetZoomRect*/
  188.  
  189. /*----------*/
  190. /*void DoZoom        (WindowPtr        whichWindow,*/
  191. /*                 short            inOrOut)*/
  192. /*{*/
  193. /*    if (TrackBox (whichWindow, curEvent.where, inOrOut)) {*/
  194. /*        EraseRect  (&whichWindow->portRect);*/
  195. /*        if ((inOrOut == inZoomOut) && sysConfig.hasColorQD) {*/
  196. /*            SetZoomRect (whichWindow, inOrOut);*/
  197. /*        }*/
  198. /*        ZoomWindow (whichWindow, inOrOut, false);*/
  199. /*        InvalRect (&whichWindow->portRect);*/
  200. /*        ResizeContent ();*/
  201. /*        ResizeScrollBars ();*/
  202. /*    }*/
  203. /*}*/ /*DoZoom*/
  204.  
  205. /* Windowing */
  206.